#include <stdio.h>
#include <stdlib.h>

//定义一个日期结构体
struct Date
{
    int year;
    int month;
    int day;
};

//定义一个学生结构体
struct Student
{
    char id[10];
    char name[20];
    char sex[4];
    struct Date birthday;
    int score[4];
};

int main()
{
    //声明函数
    struct Student stu_score(struct Student, int);
    //定义结构体变量并初始化
    struct Student stu = {"0001", "小珍", "女", {2002, 04, 01}, {100, 99, 98}};
    stu = stu_score(stu, 3);
    printf("=====学生信息=====\n");
    printf("%s %s %s %4d %2d %2d %3d %3d %3d %3d\n",
           stu.id, stu.name, stu.sex,
           stu.birthday.year, stu.birthday.month, stu.birthday.day,
           stu.score[0], stu.score[1], stu.score[2], stu.score[3]);

    return 0;
}

//定义一个统计分数的函数
struct Student stu_score(struct Student stu, int n)
{
    for (int i = 0; i < n; i++)
    {
        stu.score[3] = stu.score[i] + stu.score[3];
    }
    return stu;
}